﻿<UserControl x:Class="NthDownload.Views.DownloadPluginSelectorView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:cal="http://www.caliburnproject.org"
             xmlns:triggers="clr-namespace:NthDownload.Common.Interactivity.Triggers;assembly=NthDownload.Common"
             xmlns:behaviors="clr-namespace:NthDownload.Common.Interactivity.Behaviors;assembly=NthDownload.Common"
             xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
             mc:Ignorable="d">
    <Grid Name="RootElement">
        <i:Interaction.Triggers>
            <triggers:KeyTrigger Key="Escape">
                <cal:ActionMessage MethodName="Cancel" />
            </triggers:KeyTrigger>
        </i:Interaction.Triggers>
        
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="Auto" />
        </Grid.ColumnDefinitions>

        <Button Name="Cancel" Content="X" Margin="0,-15,5,5" Grid.Row="0" Grid.ColumnSpan="3" Style="{StaticResource XButton}"
                HorizontalAlignment="Right" />

        <Button Name="ScrollLeft" Content="&lt;" Height="150" Margin="6,0,9,0" Grid.Row="1" Style="{StaticResource ScrollButton}">
            <i:Interaction.Behaviors>
                <behaviors:FocusOnLoad />
            </i:Interaction.Behaviors>
            <i:Interaction.Triggers>
                <triggers:SrollTrigger EventName="Click" Delta="-100" DeltaDirection="Horizontal" TargetScrollViewer="{Binding ElementName=pluginScrollViewer}" />
            </i:Interaction.Triggers>
        </Button>

        <ScrollViewer Name="pluginScrollViewer" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Disabled" IsTabStop="False" Grid.Column="1" Grid.Row="1">
            <ItemsControl ItemsSource="{Binding DownloadPlugins}" IsTabStop="False">
                <i:Interaction.Triggers>
                    <triggers:SrollTrigger EventName="MouseWheel" DeltaDirection="Horizontal" TargetScrollViewer="{Binding ElementName=pluginScrollViewer}" />
                </i:Interaction.Triggers>
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <Button Content="{Binding DisplayName}" Height="150" Width="150" Margin="2.5,0,2.5,0" Style="{StaticResource PluginSelector}"
                                cal:Message.Attach="[Event Click] = [Action Select($dataContext)]"/>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <StackPanel Orientation="Horizontal" Background="#00FFFFFF" />
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
            </ItemsControl>
        </ScrollViewer>

        <Button Name="ScrollRight" Content="&gt;" Height="150" Margin="10,0,5,0" Grid.Column="2" Grid.Row="1" Style="{StaticResource ScrollButton}">
            <i:Interaction.Triggers>
                <triggers:SrollTrigger EventName="Click" Delta="100" DeltaDirection="Horizontal" TargetScrollViewer="{Binding ElementName=pluginScrollViewer}" />
            </i:Interaction.Triggers>
        </Button>
    </Grid>
</UserControl>
